-- require "prefabs/rg_foods_prefab"
local ingredients = require "cooking".ingredients
local all = require "prefabs/rg_foods_all"

local cooktags = {"fruit", "veggie", "meat"}

local HasFoodTag = function(inst, tag)
	return inst.foodtags[tag]
end

for k,v in pairs(all)do
	RG_AddPrefabPostInit(k, function(inst)
		inst.foodtags = {}
		inst.HasFoodTag = HasFoodTag
		for _,tag in ipairs(v.tags or {})do
			inst.foodtags[tag] = true
		end
		if ingredients[k] and ingredients[k].tags then
			for _,tag in ipairs(cooktags)do
				if ingredients[k].tags[tag] then
					inst.foodtags[tag] = true
				end
			end
		end

		if k:find("cap") then
			inst.foodtags[tag] = true
		end

		--@--
		v.sanity = v.sanity or 100
		v.health = v.health or 100
		inst.components.edible.healthvalue = assert(v.health)
		inst.components.edible.sanityvalue = assert(v.sanity)
	end)
end

